<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>fasty</title>
    <script src="./fasty.js"></script>
    <script src="./test/jquery.min.js"></script>
</head>
<div style="display: none" id="text">jquery获取内容</div>

<body>
<script>
    var template = "";
    var data = {"title": "title test", "content": "content test..."};
    var fasty = new Fasty({
        share: {
            name: "fasty",
            sexString: function (v) {
                return v === 0 ? '女' : '男';
            }
        }
    });


    template = "1.text";
    console.log(fasty.render(template, data))

    template = "2.{{~ var x = 100}} {{x}}";
    console.log(fasty.render(template, data))

    template = "3.{{\"hello world\"}}";
    console.log(fasty.render(template, data))

    template = '4.{{* "<div> hello world </div>"}}';
    console.log(fasty.render(template, data))

    template = '5.{{! "&lt;div&gt; hello world &lt;/div&gt;"}}';
    console.log(fasty.render(template, data))

    template = '6.{{~ var array = [1,2,3]}}  {{~ for(item of array)}}  ---item:{{item}}-- {{~end}}';
    console.log(fasty.render(template, data))

    template = '7.{{~ var array = ["aaa","aa.bb",title.length]}}  {{~ for(item of array)}}  ---item:{{item}}-- {{~end}}';
    console.log(fasty.render(template, data))

    template = '8.{{~ var array = ["aaa","aa.bb",title.length]}}  {{~ for(item in array)}}  ---item:{{item}}-- {{~end}}';
    console.log(fasty.render(template, data))

    template = '9.{{~ var array = ["aaa","aa.bb",title.length]}}  {{~ for(var i=0;i<array.length;i++)}}  ---item:{{array[i]}}-- {{~end}}';
    console.log(fasty.render(template, data))

    template = '10.{{~ for(var i=0;i< Object.keys(data).length;i++)}}  ---item:{{Object.keys(data)[i]}}-- {{~end}}';
    console.log(fasty.render(template, data))

    template = '11.test function  --- {{sexString(0)}} --- {{sexString(1)}} ';
    console.log(fasty.render(template, data))

    template = '12.{{~ var array = ["aaa","aa.bb"]}}  ' +
        '{{~ for(var i=0;i<array.length;i++)}} ' +
        ' ---item:{{array[i]}}-- ' +
        ' {{~ for( x of array[i])}}' +
        ' {{x}}-' +
        ' {{~end}}' +
        '{{~end}}';
    console.log(fasty.render(template, data))

    template = '13.{{~ if (title == content)}}  ' +
        '>>aaa ' +
        '{{~elseif (title.length === 10)}}' +
        '>>>>bbbb' +
        '{{~else}}' +
        '>>>cccc' +
        '{{~end}}';
    console.log(fasty.render(template, data))


    template = '14.{{~ var array = ["aaa","aa.bb",title.length],other1="aaa,cc,dd",other2=123,other3 = title.length}}' +
        '  {{~ for(var i=0;i<array.length;i++)}}  ' +
        '---item:{{array[i]}}-- ' +
        '{{~end}}'+
        '{{other1}} '+
        '{{other2}} '+
        '{{other3}} ';
    console.log(fasty.render(template, data))


    template = '15.{{ $("#text").text() }} ';
    console.log(fasty.render(template, data))

</script>

</body>

</html>
